package utility;

import java.util.ArrayList;
import java.util.Arrays;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class Utility {
	public static void debug(Object... os) {
		JOptionPane.showMessageDialog(new JFrame(), Arrays.deepToString(os));
	}
	
	public static int maxIndex(ArrayList<Double> series)
	{
		double max = series.get(0);
		int index = 0;
		for (int i = 1; i < series.size(); ++i)
		{
			if (series.get(i) > max)
			{
				max = series.get(i);
				index = i;
			}
		}
		return index;
	}
	
	public static int minIndex(ArrayList<Double> series)
	{
		double min = series.get(0);
		int index = 0;
		for (int i = 1; i < series.size(); ++i)
		{
			if (series.get(i) < min)
			{
				min = series.get(i);
				index = i;
			}
		}
		return index;
	}
	
	public static ArrayList<Double> subList(ArrayList<Double> series, int fromIndex, int toIndex)
	{
		ArrayList<Double> result = new ArrayList<Double>();
		for (int i = fromIndex; i <= toIndex; ++i)
		{
			result.add(series.get(i));
		}
		return result;
	}
}
